package com.meilele.dao.guoziyang;

import com.meilele.entity.guoziyang.SecShow;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SecShowMapper {
    @Delete({
        "delete from sec_show",
        "where show_id = #{showId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer showId);

    @Insert({
        "insert into sec_show (show_id, show_image)",
        "values (#{showId,jdbcType=INTEGER}, #{showImage,jdbcType=VARCHAR})"
    })
    int insert(SecShow record);

    int insertSelective(SecShow record);

    @Select({
        "select",
        "show_id, show_image",
        "from sec_show",
        "where show_id = #{showId,jdbcType=INTEGER}"
    })
    @ResultMap("com.meilele.dao.guoziyang.SecShowMapper.BaseResultMap")
    SecShow selectByPrimaryKey(Integer showId);

    int updateByPrimaryKeySelective(SecShow record);

    @Update({
        "update sec_show",
        "set show_image = #{showImage,jdbcType=VARCHAR}",
        "where show_id = #{showId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(SecShow record);

@Results(value = {
        @Result ( column="show_image",  property="showImage" ),
        @Result(column = "show_name" ,property = "imageName")
})
@Select({
        "SELECT show_image,show_name FROM sec_show sw INNER JOIN sec_detail dl ON sw.image_detail = dl.style_id WHERE dl.style_id = #{styleId}"
})
    List<SecShow> findDetaidImage(int styleId);


    int insertShow(SecShow secShow);

    /*
      此项为删除detail时删除show表中对应的数据
     */

    @Delete({"DELETE FROM sec_show WHERE image_detail = #{styleId}"})
    int deleteShow(@Param("styleId") int styleId);

    /*
    此方法用来删除中间表对应detail的信息
     */
    @Delete({"DELETE FROM sec_laber_detail WHERE sec_detailID=#{styleId}"})
    int deleteDeLa(@Param("styleId") int styleId);

}